/**
 * <copyright>
 *
 * Copyright (c) 2011 Zeligsoft (2009) Limited
 * All rights reserved.   This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * 
 * Contributors: 
 *   Zeligsoft (2009) Limited - Initial API and implementation
 *
 * </copyright>
 *
 */
package org.omg.xmi.impl;

import java.util.Collection;

import org.eclipse.emf.common.notify.NotificationChain;

import org.eclipse.emf.common.util.EList;

import org.eclipse.emf.ecore.EClass;
import org.eclipse.emf.ecore.InternalEObject;

import org.eclipse.emf.ecore.impl.EObjectImpl;

import org.eclipse.emf.ecore.util.BasicFeatureMap;
import org.eclipse.emf.ecore.util.FeatureMap;
import org.eclipse.emf.ecore.util.InternalEList;

import org.omg.xmi.Add;
import org.omg.xmi.Delete;
import org.omg.xmi.Difference;
import org.omg.xmi.Documentation;
import org.omg.xmi.Extension;
import org.omg.xmi.Replace;
import org.omg.xmi.XMI;
import org.omg.xmi.XMIPackageType;
import org.omg.xmi.XmiPackage;

/**
 * <!-- begin-user-doc -->
 * An implementation of the model object '<em><b>XMI Package Type</b></em>'.
 * <!-- end-user-doc -->
 * <p>
 * The following features are implemented:
 * <ul>
 *   <li>{@link org.omg.xmi.impl.XMIPackageTypeImpl#getGroup <em>Group</em>}</li>
 *   <li>{@link org.omg.xmi.impl.XMIPackageTypeImpl#getDifference <em>Difference</em>}</li>
 *   <li>{@link org.omg.xmi.impl.XMIPackageTypeImpl#getAdd <em>Add</em>}</li>
 *   <li>{@link org.omg.xmi.impl.XMIPackageTypeImpl#getReplace <em>Replace</em>}</li>
 *   <li>{@link org.omg.xmi.impl.XMIPackageTypeImpl#getDelete <em>Delete</em>}</li>
 *   <li>{@link org.omg.xmi.impl.XMIPackageTypeImpl#getXMI <em>XMI</em>}</li>
 *   <li>{@link org.omg.xmi.impl.XMIPackageTypeImpl#getDocumentation <em>Documentation</em>}</li>
 *   <li>{@link org.omg.xmi.impl.XMIPackageTypeImpl#getExtension <em>Extension</em>}</li>
 * </ul>
 * </p>
 *
 * @generated
 */
public class XMIPackageTypeImpl extends EObjectImpl implements XMIPackageType {
	/**
	 * The cached value of the '{@link #getGroup() <em>Group</em>}' attribute list.
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @see #getGroup()
	 * @generated
	 * @ordered
	 */
	protected FeatureMap group;

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	protected XMIPackageTypeImpl() {
		super();
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	protected EClass eStaticClass() {
		return XmiPackage.Literals.XMI_PACKAGE_TYPE;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public FeatureMap getGroup() {
		if (group == null) {
			group = new BasicFeatureMap(this,
					XmiPackage.XMI_PACKAGE_TYPE__GROUP);
		}
		return group;
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Difference> getDifference() {
		return getGroup()
				.list(XmiPackage.Literals.XMI_PACKAGE_TYPE__DIFFERENCE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Add> getAdd() {
		return getGroup().list(XmiPackage.Literals.XMI_PACKAGE_TYPE__ADD);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Replace> getReplace() {
		return getGroup().list(XmiPackage.Literals.XMI_PACKAGE_TYPE__REPLACE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Delete> getDelete() {
		return getGroup().list(XmiPackage.Literals.XMI_PACKAGE_TYPE__DELETE);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<XMI> getXMI() {
		return getGroup().list(XmiPackage.Literals.XMI_PACKAGE_TYPE__XMI);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Documentation> getDocumentation() {
		return getGroup().list(
				XmiPackage.Literals.XMI_PACKAGE_TYPE__DOCUMENTATION);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	public EList<Extension> getExtension() {
		return getGroup().list(XmiPackage.Literals.XMI_PACKAGE_TYPE__EXTENSION);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public NotificationChain eInverseRemove(InternalEObject otherEnd,
			int featureID, NotificationChain msgs) {
		switch (featureID) {
		case XmiPackage.XMI_PACKAGE_TYPE__GROUP:
			return ((InternalEList<?>) getGroup()).basicRemove(otherEnd, msgs);
		case XmiPackage.XMI_PACKAGE_TYPE__DIFFERENCE:
			return ((InternalEList<?>) getDifference()).basicRemove(otherEnd,
					msgs);
		case XmiPackage.XMI_PACKAGE_TYPE__ADD:
			return ((InternalEList<?>) getAdd()).basicRemove(otherEnd, msgs);
		case XmiPackage.XMI_PACKAGE_TYPE__REPLACE:
			return ((InternalEList<?>) getReplace())
					.basicRemove(otherEnd, msgs);
		case XmiPackage.XMI_PACKAGE_TYPE__DELETE:
			return ((InternalEList<?>) getDelete()).basicRemove(otherEnd, msgs);
		case XmiPackage.XMI_PACKAGE_TYPE__XMI:
			return ((InternalEList<?>) getXMI()).basicRemove(otherEnd, msgs);
		case XmiPackage.XMI_PACKAGE_TYPE__DOCUMENTATION:
			return ((InternalEList<?>) getDocumentation()).basicRemove(
					otherEnd, msgs);
		case XmiPackage.XMI_PACKAGE_TYPE__EXTENSION:
			return ((InternalEList<?>) getExtension()).basicRemove(otherEnd,
					msgs);
		}
		return super.eInverseRemove(otherEnd, featureID, msgs);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public Object eGet(int featureID, boolean resolve, boolean coreType) {
		switch (featureID) {
		case XmiPackage.XMI_PACKAGE_TYPE__GROUP:
			if (coreType)
				return getGroup();
			return ((FeatureMap.Internal) getGroup()).getWrapper();
		case XmiPackage.XMI_PACKAGE_TYPE__DIFFERENCE:
			return getDifference();
		case XmiPackage.XMI_PACKAGE_TYPE__ADD:
			return getAdd();
		case XmiPackage.XMI_PACKAGE_TYPE__REPLACE:
			return getReplace();
		case XmiPackage.XMI_PACKAGE_TYPE__DELETE:
			return getDelete();
		case XmiPackage.XMI_PACKAGE_TYPE__XMI:
			return getXMI();
		case XmiPackage.XMI_PACKAGE_TYPE__DOCUMENTATION:
			return getDocumentation();
		case XmiPackage.XMI_PACKAGE_TYPE__EXTENSION:
			return getExtension();
		}
		return super.eGet(featureID, resolve, coreType);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@SuppressWarnings("unchecked")
	@Override
	public void eSet(int featureID, Object newValue) {
		switch (featureID) {
		case XmiPackage.XMI_PACKAGE_TYPE__GROUP:
			((FeatureMap.Internal) getGroup()).set(newValue);
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__DIFFERENCE:
			getDifference().clear();
			getDifference().addAll((Collection<? extends Difference>) newValue);
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__ADD:
			getAdd().clear();
			getAdd().addAll((Collection<? extends Add>) newValue);
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__REPLACE:
			getReplace().clear();
			getReplace().addAll((Collection<? extends Replace>) newValue);
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__DELETE:
			getDelete().clear();
			getDelete().addAll((Collection<? extends Delete>) newValue);
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__XMI:
			getXMI().clear();
			getXMI().addAll((Collection<? extends XMI>) newValue);
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__DOCUMENTATION:
			getDocumentation().clear();
			getDocumentation().addAll(
					(Collection<? extends Documentation>) newValue);
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__EXTENSION:
			getExtension().clear();
			getExtension().addAll((Collection<? extends Extension>) newValue);
			return;
		}
		super.eSet(featureID, newValue);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public void eUnset(int featureID) {
		switch (featureID) {
		case XmiPackage.XMI_PACKAGE_TYPE__GROUP:
			getGroup().clear();
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__DIFFERENCE:
			getDifference().clear();
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__ADD:
			getAdd().clear();
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__REPLACE:
			getReplace().clear();
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__DELETE:
			getDelete().clear();
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__XMI:
			getXMI().clear();
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__DOCUMENTATION:
			getDocumentation().clear();
			return;
		case XmiPackage.XMI_PACKAGE_TYPE__EXTENSION:
			getExtension().clear();
			return;
		}
		super.eUnset(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public boolean eIsSet(int featureID) {
		switch (featureID) {
		case XmiPackage.XMI_PACKAGE_TYPE__GROUP:
			return group != null && !group.isEmpty();
		case XmiPackage.XMI_PACKAGE_TYPE__DIFFERENCE:
			return !getDifference().isEmpty();
		case XmiPackage.XMI_PACKAGE_TYPE__ADD:
			return !getAdd().isEmpty();
		case XmiPackage.XMI_PACKAGE_TYPE__REPLACE:
			return !getReplace().isEmpty();
		case XmiPackage.XMI_PACKAGE_TYPE__DELETE:
			return !getDelete().isEmpty();
		case XmiPackage.XMI_PACKAGE_TYPE__XMI:
			return !getXMI().isEmpty();
		case XmiPackage.XMI_PACKAGE_TYPE__DOCUMENTATION:
			return !getDocumentation().isEmpty();
		case XmiPackage.XMI_PACKAGE_TYPE__EXTENSION:
			return !getExtension().isEmpty();
		}
		return super.eIsSet(featureID);
	}

	/**
	 * <!-- begin-user-doc -->
	 * <!-- end-user-doc -->
	 * @generated
	 */
	@Override
	public String toString() {
		if (eIsProxy())
			return super.toString();

		StringBuffer result = new StringBuffer(super.toString());
		result.append(" (group: ");
		result.append(group);
		result.append(')');
		return result.toString();
	}

} //XMIPackageTypeImpl
